//
//  SingleCollectionViewCell.m
//  半糖
//
//  Created by RenShuang on 15/9/16.
//  Copyright (c) 2015年 shuang. All rights reserved.
//

#import "SingleCollectionViewCell.h"

@implementation SingleCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH-30)/2, SCREEN_WIDTH/2-40)];
        [self.contentView addSubview:self.picImageView];
        [self.picImageView release];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_WIDTH/2-40, SCREEN_WIDTH/2-15, 40)];
       // _titleLabel.backgroundColor = [UIColor whiteColor];
        _titleLabel.font = [UIFont systemFontOfSize:15.];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
    }
    return self;
}

- (void)getModel:(SingleModel *)model key:(NSString *)string
{
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:model.title];
    NSRange range = [model.title rangeOfString:string];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range];
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]placeholderImage:[UIImage imageNamed:@"占位图.png"]];
    self.titleLabel.attributedText = attributedString;
}

@end
